Support enum and array based attributes in codegen#1898
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the Kotlin semantic-convention codegen templates to support enum-typed attributes (and prepares support for array-typed attributes), then switches a few Android internal semantic conventions and instrumentations to use the generated enums instead of hard-coded strings.
Changes:
- Update Kotlin weaver/codegen templates to (a) skip
any-typed event attributes, (b) generateAttributeKeyconstants for array types, and (c) generate enum “Values” types for enum attributes. - Update the Android semconv registry to express
screen.orientation,start.type, andwebsocket.message.typeas enums. - Update instrumentation code to use the generated enum values (e.g.,
StartTypeValues.COLD.value) instead of string literals.
PR Merge Tier: Tier 3 (build/codegen changes + cross-module behavior wiring)
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
semconv/templates/registry/kotlin/weaver.yaml |
Adds type mappings for array AttributeKey generation and filters out any-typed event attributes. |
semconv/templates/registry/kotlin/kotlin_semconv_template.kt.j2 |
Generates AttributeKey fields for array types and emits enum value classes for enum attributes. |
semconv/templates/registry/kotlin/kotlin_event_template.kt.j2 |
Adds array-attribute handling via AttributeKey.*ArrayKey(...) when emitting event attributes. |
semconv/model/android/registry.yaml |
Converts several attributes from string to enum definitions with members. |
instrumentation/screen-orientation/.../ScreenOrientationDetector.kt |
Uses generated ScreenOrientationValues instead of hard-coded orientation strings. |
instrumentation/okhttp3-websocket/.../WebsocketListenerWrapper.kt |
Uses generated WebsocketMessageTypeValues instead of hard-coded message type strings. |
instrumentation/activity/.../AppStartupTimer.kt |
Uses generated StartTypeValues.COLD.value instead of "cold". |
instrumentation/activity/.../ActivityTracer.kt |
Uses generated StartTypeValues.{WARM,HOT}.value instead of "warm"/"hot". |
LikeTheSalad
left a comment
There was a problem hiding this comment.
Thanks! I think it's worth checking the comment from Copilot, but overall LGTM.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1898 +/- ##
==========================================
+ Coverage 64.89% 65.33% +0.43%
==========================================
Files 168 169 +1
Lines 3723 3871 +148
Branches 390 420 +30
==========================================
+ Hits 2416 2529 +113
- Misses 1194 1211 +17
- Partials 113 131 +18 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Fixed attribute templates to work with enum and array-based attribute values. Add in some codegen to create enums and then changed a few internal semconv to use them.